package net.servir.censo.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import net.servir.censo.model.Sistema;
import net.servir.censo.service.CensoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class BienvenidoCensoController {

	@Autowired
	private CensoService censoService;
	@RequestMapping("/bienvenidoCenso.htm")
	public @ModelAttribute("bienvenidoServir")
	Sistema bienvenido(HttpServletRequest request) {

		HttpSession session = request.getSession();
		Integer dniSistema = (Integer) session.getAttribute("id_sistema");
		Integer idAmbito = ((Integer) session.getAttribute("id_ambito")).intValue();
		String dni_responsable = session.getAttribute("dni").toString();
		System.out.println(idAmbito);
		System.out.println(dni_responsable);
		return 	censoService.getSistema(dniSistema,dni_responsable,idAmbito);
	}
}
